package cn.itcast.nems.studentrecord.dao.mapper;

import cn.itcast.nems.studentrecord.dao.entity.StudentRecordPayment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;

import java.util.List;

@Mapper
public interface StudentRecordPaymentMapper extends BaseMapper<StudentRecordPayment> {
    /**
     * 根据学籍ID 及 状态筛选学籍支付记录 <br>
     * 按照修改时间倒叙排列
     *
     * @param studentRecordId 学籍ID
     * @param stateList       状态
     * @return 学籍支付记录
     */
    List<StudentRecordPayment> queryByStudentRecordId(@Param("studentRecordId") @NonNull String studentRecordId,
                                                      @Param("stateList") @Nullable List<String> stateList);

    /**
     * 取消pending状态的记录
     *
     * @param studentRecordId 学籍
     * @return 影响行数
     */
    int cancelOtherPendingRecordByStudentRecordId(@Param("studentRecordId") @NonNull String studentRecordId);

    /**
     * 根据商户订单号获取学籍支付记录
     *
     * @param merchantOrderNo 商户订单号
     * @return 学籍支付记录
     */
    StudentRecordPayment queryByMerchantOrderNo(@NonNull String merchantOrderNo);
}
